package com.study.spmongodb.book.wwj.char01;

import java.util.concurrent.TimeUnit;

/**
 * @author study
 * @version 1.0
 * @date 2020/11/23 16:35
 */
public class TryConcurrency {
    public static void main(String[] args) {
        // browseNews();
        new Thread(TryConcurrency::browseNews).start();
        engjoyMusic();
    }

    private static void browseNews() {
        for (; ; ) {
            System.out.println("Uh-huh,the good news");
            sleep(1);
        }
    }

    private static void sleep(int i) {
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    private static void engjoyMusic() {
        for (; ; ) {
            System.out.println("Uh-hh,the nice music.");
            sleep(1);
        }
    }
}
